package net.csdn.business.common.oauth2.mapper;

import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.csdn.business.common.oauth2.model.entity.GatewayRouteInfo;
import net.csdn.business.common.domain.request.oauth.GatewayRouteInfoQuery;
import net.csdn.business.common.domain.vo.oauth.GatewayRouteInfoVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * 网关路由信息Mapper接口
 * 
 * @author zhangyl
 * @date 2022-12-13
 */
@Repository
public interface GatewayRouteInfoMapper extends BaseMapper<GatewayRouteInfo>
{

    /**
     * 分页查询网关路由信息列表
     *
     * @param query 字典类型信息
     * @return 字典类型集合信息
     */
    @Select("<script> select * from gateway_route_info " +
            "where 1=1 " +
            "<if test='query.routeName != null  and query.routeName != \"\"'> " +
            "and route_name like concat('%', #{query.routeName}, '%')" +
            "</if>" +
            "<if test='query.routeId != null  and query.routeId != \"\"'> " +
            "and route_id like concat('%', #{query.routeId}, '%')" +
            "</if>" +
            "<if test='query.reqPath != null  and query.reqPath != \"\"'> " +
            "and req_path like concat('%', #{query.reqPath}, '%')" +
            "</if>" +
            "<if test='query.reqPath != null  and query.reqPath != \"\"'> " +
            "and req_path like concat('%', #{query.reqPath}, '%')" +
            "</if>" +
            "<if test='query.uri != null  and query.uri != \"\"'> " +
            "and uri like concat('%', #{query.uri}, '%')" +
            "</if>" +
            "<if test='query.reqMethod != null  and query.reqMethod != \"\"'> " +
            "and req_method = #{query.reqMethod}" +
            "</if>" +
            "<if test='query.beginTime != null and query.beginTime != \"\" and query.endTime != null and query.endTime != \"\"'>\n" +
            "AND created_date  BETWEEN  CONCAT(#{query.beginTime}, ' 00:00:00' )\n" +
            "AND CONCAT( #{query.endTime}, ' 23:59:59' )\n" +
            "</if>" +
            "order by created_date desc" +
            "</script>")
    public List<GatewayRouteInfoVO> findPageList(Page page, @Param("query") GatewayRouteInfoQuery query);

    /**
     * 查询网关路由信息
     *
     * @param id 网关路由信息主键
     * @return 网关路由信息
     */
    @Select("<script> select * from gateway_route_info " +
            "where id= #{id}" +
            "</script>")
    public GatewayRouteInfoVO selectGatewayRouteInfoById(@Param("id")Long id);

    /**
     * 查询所有网关路由信息列表
     * @return 网关路由信息集合
     */
    @Select("<script> select * from gateway_route_info " +
            "</script>")
    public List<GatewayRouteInfo> selectGatewayRouteInfoList();


}
